package concurrent.year2021;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

public class ThreadStateTest {
    public static void main(String[] args) throws InterruptedException {
        Lock l = new ReentrantLock();
        Condition c = l.newCondition();
        new Thread(() -> {
            try {
                l.lockInterruptibly(); // wait
                //TimeUnit.DAYS.sleep(10); // sleeping, TIMED_WAITING
                c.await(); // wait
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }, "haha").start();
        TimeUnit.SECONDS.sleep(5);
        l.lock(); // wait
        System.out.println("end");
    }
}
